package com.csx.data.orm.jpa.batch.repositories;

import com.csx.data.orm.jpa.base.entity.User;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;
import java.util.List;

@Repository
public interface UserBatchRepository extends CrudRepository<User, Long> {


    @Lock(LockModeType.PESSIMISTIC_WRITE)
    @Query("SELECT u FROM User u")
    List<User> findAllWithLock();

}
